import { toFail, toSuccess, useEntityManager } from "@sker/core"
import { KsPackage } from "@sker/entities"
import { useData } from "@sker/runtime"
import { z } from "zod"

/**
 * 检查
 */
export default async () => {
    const input = z.object({
        name: z.string(),
        uuid: z.string()
    })
    const body = input.parse(useData())
    return await useEntityManager(async m => {
        const item = await m.findOne(KsPackage, { where: { name: body.name }, order: { version: 'desc'} })
        if(item) return toSuccess(item)
        else return toFail(`参数有误`)
    });
}
